﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddTreeLocations.aspx.cs" Inherits="ForestryEnterprise.AddTreeLocations" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <h2>Add Tree Locations</h2>
        <hr />
        <label>Pick tree:</label>
        <asp:DropDownList ID="trees" runat="server" 
            onselectedindexchanged="trees_SelectedIndexChanged" AutoPostBack="true" />
        <label style="margin-left:50px;">Pick existing location:</label>
        <asp:DropDownList ID="locations" runat="server" AutoPostBack="true" 
            onselectedindexchanged="locations_SelectedIndexChanged"/>
        <br />
        <label>Location name:</label>
        <asp:TextBox id="locName" runat="server" />
        <br />
        <label>Location country:</label>
        <asp:TextBox id="locCountry" runat="server" />
        <asp:RequiredFieldValidator ID="reqCountry" ControlToValidate="locCountry" ErrorMessage="Must provide country" runat="server" />
        <br />
        <label>Location area:</label>
        <asp:TextBox id="locArea" runat="server" />
        <asp:RequiredFieldValidator ID="reqArea" ControlToValidate="locArea" ErrorMessage="Must provide area" runat="server" />
        <br />
        <label>Location altitude:</label>
        <asp:TextBox id="locAltitude" runat="server" />
        <asp:RequiredFieldValidator ID="reqAltitude" ControlToValidate="locAltitude" ErrorMessage="Must input Altitude " runat="server" Display="Dynamic"/>
        <asp:RegularExpressionValidator ID="regAlt" ControlToValidate="locAltitude" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Number (float point)" runat="server" Display="Dynamic"/>
        <br />
        <label>Location latitude:</label>
        <asp:TextBox id="locLatitude" runat="server" />
        <asp:RequiredFieldValidator ID="reqLatitude" ControlToValidate="locLatitude" ErrorMessage="Must input Latitude " runat="server" Display="Dynamic"/>
        <asp:RegularExpressionValidator ID="regLat" ControlToValidate="locLatitude" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Number (float point)" runat="server" Display="Dynamic"/>
        <br />
        <label>Location longitude:</label>
        <asp:TextBox id="locLongitude" runat="server" />
        <asp:RequiredFieldValidator ID="reqLong" ControlToValidate="locLongitude" ErrorMessage="Must input Longitude " runat="server" Display="Dynamic"/>
        <asp:RegularExpressionValidator ID="regLong" ControlToValidate="locLongitude" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Number (float point)" runat="server" Display="Dynamic"/>
        <br />
        <asp:Button ID="addNewLoc" Text="Add New" runat="server" 
            onclick="addNewLoc_Click" />
        <asp:Button ID="updateLoc" Text="Update" runat="server" Enabled="false" 
            onclick="updateLoc_Click" />
        <hr />
        <asp:GridView ID="treeLocations" runat="server" AutoGenerateColumns="false" DataSourceID="treeLocationsDB" DataKeyNames="l_id">
            <Columns>
                <asp:BoundField DataField="l_name" HeaderText="Name" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="l_country" HeaderText="Country" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="l_area" HeaderText="Area" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="l_altitude" HeaderText="Altitude" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="l_latitude" HeaderText="Latitude" InsertVisible="false" ReadOnly="true" />
                <asp:BoundField DataField="l_longitude" HeaderText="Longitude" InsertVisible="false" ReadOnly="true" />
            </Columns> 
        </asp:GridView>
        <asp:AccessDataSource ID="treeLocationsDB" DataFile="~/App_Data/ForestryEnterprise.mdb" runat="server"/>
        <asp:Label ID="err" runat="server" style="color:Red;"/>
    </form>
</body>
</html>
